home *** CD-ROM | disk | FTP | other *** search
- //---------------------------------------------------------------------------
- #include <condefs.h>
- #include <conio.h>
- #include <iostream.h>
- #pragma hdrstop
-
- //---------------------------------------------------------------------------
- int x = 20;
- void CountLoops(int);
-
- int main(int, char**)
- {
- int x = 40;
- int i = 0;
- cout << "In main program x = " << x << endl;
- bool done = false;
- while (!done) {
- int x;
- cout << endl << "Enter a number (-1 to exit): ";
- cin >> x;
- if (x != -1) {
- cout << endl << "In while loop x = " << x;
- CountLoops(++i);
- }
- else
- done = true;
- }
- cout << "Global x = " << ::x << endl;
- cout << endl << "Press any key to continue...";
- getch();
- return 0;
- }
- void CountLoops(int x)
- {
- cout << ", While loop has executed "
- << x << " times" << endl;
- }
-
-